<!-- Sofija Puric 6/08 -->
<?php

if (!(isset($_SESSION['username']) && $_SESSION['username']!=""))
     header('Location: hostels.php?err=6');
$uname = $_SESSION['username'];

require 'pages/db.php';
$con=dbConnect("sib");

$sql_user = "SELECT * FROM user WHERE UserName = '$uname'";
$result_user = mysql_query($sql_user, $con);
if (!$result_user)
    die('Error: ' . mysql_error());
else $row_user=mysql_fetch_array($result_user);

$hid=$_GET["hid"];
$sql_hostel = "SELECT * FROM hostel WHERE IDHostel = '$hid'";
$result_hostel = mysql_query($sql_hostel, $con);
if (!$result_hostel)
    die('Error: ' . mysql_error());
else $row_hostel=mysql_fetch_array($result_hostel);

echo '<div id="book">
    <h2>'.$row_hostel["Name"].'</h2><br /><br />
    <form name = "reservation_form" action =
    "pages/reservate_hostel.php?hid='.$row_hostel["IDHostel"].'&uid='.$row_user["IDUser"].'&hname='.$row_hostel["Name"].'" method = "post">
        <table>
            <tr>
                <td>Name:</td>
                <td><input type="text" name="name" value = '.$row_user["FirstName"].' readonly = "readonly" /></td>
            </tr>
            <tr>
                <td>Surname:</td>
                <td><input type="text" name="surname" value = '.$row_user["LastName"].' readonly = "readonly" /></td>
            </tr>
            <tr>
                <td>Mail:</td>
                <td><input type="text" name="mail" value = '.$row_user["Email"].' readonly = "readonly" /></td>
            </tr>
            <tr>
                <td>Address:</td>
                <td><input type="text" name="addr" /></td>
            </tr>
            <tr>
                <td>Phone:</td>
                <td><input type="text" name="phone"  value = '.$row_user["Phone"].' readonly = "readonly" /></td>
            </tr>
            <tr>
                <td>Bed number:</td>
                <td><input type="text" size="3" name="beds" /></td>
            </tr>   
            <tr>
                <td>Date from:</td>
                <td><input type="text" size="10" name="from" class="date-pick"/></td>
            </tr>
            <tr>
                <td>Date to: </td>
                <td><input type="text" size="10" name="to" class="date-pick"/></td>
            </tr>
            <tr>
                <td colspan="2"><button type="submit">Book!</button></td>
            </tr>
        </table>
    </form>
    </div>';

mysql_close($con);

?>
